package com.naiterui.ehp.bs.emr.controller.patient;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.naiterui.ehp.bp.bo.smh.SmhUserBO;
import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.constants.SwaggerTags;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bp.support.exception.PublicService;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bs.emr.service.IHisService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 患者his线下接口
 *
 * @author guoyongxiang
 * @version 1.0.0
 * @date 2021/8/12 18:21
 **/
@Slf4j
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("emr/patient/his")
@Api(tags = SwaggerTag.PATIENT + SwaggerTag.MEDICAL_RECORD)
public class EmrHisController {

    private final IHisService hisService;

    @ApiOperation(value = "获取患者HIS就诊记录", notes = "获取患者HIS就诊记录", tags = SwaggerTags.WX_PATIENT_CASE)
    @ApiImplicitParams({@ApiImplicitParam(name = "inquirerId", value = "就诊人ID", required = true, dataType = "long",
        paramType = "query"),})
    @GetMapping("patient/records")
    public ResponseVO<SmhUserBO> getPatientRecords(Long patientId, Long inquirerId) throws BusinessException {
        log.info("查询患者线下就诊信息");
        SmhUserBO user = hisService.getPatientList(patientId, inquirerId);
        return PublicService.returnResponseVO(user);
    }
}
